import {messageDuration } from "@/config/settings";
import * as lodash from "lodash";
import { Message, MessageBox } from "element-ui";
// import store from "@/store";

const install = (Vue, opts = {}) => {
  /* 全局Message */
  Vue.prototype.$baseMessage = (message, type) => {
    Message({
      offset: 60,
      showClose: true,
      message: message,
      type: type,
      dangerouslyUseHTMLString: true,
      duration: messageDuration,
    });
  };

  /* 全局Confirm */
  Vue.prototype.$baseConfirm = (content, title, callback1, callback2,) => {
    MessageBox.confirm(content, title || "温馨提示", {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      closeOnClickModal: false,
      type: "warning",
    })
      .then(() => {
        if (callback1) {
          callback1();
        }
      })
      .catch(() => {
        if (callback2) {
          callback2();
        }
      });
  };
  /* 全局Confirm */
  Vue.prototype.$baseConfirm2 = (content, title,okBtnTex,cannelBtnTex,callback1, callback2) => {
    MessageBox.confirm(content, title || "温馨提示", {
      confirmButtonText: okBtnTex || '确定',
      cancelButtonText: cannelBtnTex || '取消',
      closeOnClickModal: false,
      type: "warning",
    })
        .then(() => {
          if (callback1) {
            callback1();
          }
        })
        .catch(() => {
          if (callback2) {
            callback2();
          }
        });
  };




  Vue.prototype.$baseLodash = lodash;
  /* 全局事件总线 */
  Vue.prototype.$baseEventBus = new Vue();
};

if (typeof window !== "undefined" && window.Vue) {
  install(window.Vue);
}

export default install;
